package com.meihua.code.domain;

public class SingleLinkedList {
  public int val;
  public SingleLinkedList next;
  public SingleLinkedList() {}
  public SingleLinkedList(int val) { this.val = val; }
  public SingleLinkedList(int val, SingleLinkedList next) {
    this.val = val; this.next = next;
  }

  public static   SingleLinkedList getSingleLinkedList(int [] arr){
    SingleLinkedList singleLinkedList = new SingleLinkedList(arr [0]);
    SingleLinkedList temp=singleLinkedList;

    for (int i=1;i<arr.length;i++){
      SingleLinkedList node =new SingleLinkedList(arr[i]);
      temp.next=node;
      temp=temp.next;
    }
    return singleLinkedList;


  }

  @Override
  public String toString() {
    return "SingleLinkedList{" +
            "val=" + val +
            ", next=" + next +
            '}';
  }
}